package com.kun.base.web.listener;

import com.kun.base.redis.RedisUtil;
import com.kun.base.shiro.service.SSOService;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * Created by admin on 2017/8/11.
 * 监听session创建或关闭
 */
public class SessionListener implements HttpSessionListener {

    @Override
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {

    }

    @Override
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        //session销毁时清空一些缓存
        RedisUtil.clearUserInfo(httpSessionEvent.getSession());
        //移除用户在线列表
        new SSOService().onlineUserRemove(httpSessionEvent.getSession());
    }

}
